#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtNetwork>

//#include <QtSerialPort/QSerialPort>
//#include <QtSerialPort/QSerialPortInfo>

#include <QtXml>
#include <QtXml/QDomDocument>


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <errno.h>
#include <string.h>
#include <QTcpServer>
#include "lus_core/lus_prase.h"

extern "C"{

#include "msg_core/common.h"
#include "msg_core/list.h"
#include "msg_core/msg_core.h"
#include "v4l2/v4l2.h"
}
#include "aes_tcp/aes_tcp.h"

class Thread_photo: public QThread
{

     Q_OBJECT

public:
    void run();
    QString name; //添加一个 name 对象
    QByteArray camera_node = "";
    QUdpSocket *th_udp_send;
    QImage image_my;
    pass_data pd;
    int get_image_flag;
    QMutex mutex;

private:



signals:
    void UpdateSignal(QImage image_my, QString node_name);


public slots:
       // void change_flag();

};


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

   lus_prase *my_lus = new lus_prase;
     aes_tcp * my_tcp = new aes_tcp;
     struct _list * p_order_list;

     int nrf_fd = 0;
     void nrf_send(char * data);
     int nrf_vaild_flag;

     void do_cmd(QByteArray cmd);

       /*串口*/
     void com_init(void);

    // QSerialPort *my_serialPort;//(实例化一个指向串口的指针，可以用于访问串口)
     Thread_photo *thread_get_image1 = new Thread_photo;
     Thread_photo *thread_get_image2 = new Thread_photo;

     QUdpSocket *udp_receiver;
     QUdpSocket *local_udp;

signals:
    void thread_get_signal();

private slots:

    void send_lus_cmd(QByteArray cmd);
    /*TCP*/
    void readMsg(QByteArray b_data);  //接收数据

    void on_pushButton_clicked();

    void on_pushButton_clean_clicked();

    void up_cook_data(char *data);

    void flushBuff(QImage image_my, QString node_name);
    /*udp read fun*/
    void processPendingDatagram();
    void do_local_udp();

private:
    Ui::MainWindow *ui;
    QByteArray tk_cmd = "<user_msg type=\"arg1\" body=\"arg2\" />";

};

#endif // MAINWINDOW_H
